﻿{% extends "base.html" %}

{% block scripts %}
{% endblock %}


{% block content %}

<h1>Главная</h1>

    <ul class="paging">
                    {% if companies.has_previous %}
                    <li class="item"><a href="/{{ companies.previous_page_number }}/"><img class="icon" src="/media/images/icon_arrow_2.gif" width="11" height="5"></a></li>
					{% endif %}

                    {% for page in companies.paginator.page_range %}
                        {% if page == companies.number %}
                            <li class="item item_current">{{ page }}</li>
                        {% else %}
                            <li class="item"> <a href="/{{ page }}/">{{ page }}</a></li>
                        {% endif %}
                    {% endfor %}

                    {% if companies.has_next %}
					<li class="item"><a href="/{{ companies.next_page_number }}/"><img class="icon" src="/media/images/icon_arrow_1.gif" width="11" height="5"></a></li>
					{% endif %}
	</ul>

				<ul class="info_list_1 home_info_list">
					{% for company in companies.object_list %}
                    <li class="list_item{% if forloop.first %} list_item_first{% endif %}">
						<img class="pic"
                         {% if company.logo %}
                            src="{{ company.logo.url }}"
                            {% if company.logo.width > company.logo.height %} width="79" {% else %} height="79" {% endif %}
                         {% else %}
                            src="/media/images/img_no.gif" width="79" height="79"
                         {% endif %}
                         />
						<div class="item_base">
							<h3 class="item_header"><a href="/company/{{ company.id }}/">{{ company.name }}</a></h3>
							<dl class="info">

								{% if company.fiz_address %}
                                    <dt>Адрес:</dt>
									<dd>{{ company.fiz_address }}</dd>
                                {% endif %}

								{% if company.phone %}
								    <dt>Телефон:</dt>
									<dd>{{ company.phone }}</dd>
                                {% endif %}

                                {% if company.worktime %}
                                    <dt>Время работы:</dt>
								    <dd>{{ company.worktime }}</dd>
                                {% endif %}

								{% if company.website %}
                                    <dt>Сайт:</dt>
									<dd><a href="http://{{ company.website }}">{{ company.website }}</a></dd>
                                {% endif %}

                                <dt>Администратор:</dt>
									<dd><a href="/profile/{{ company.owner.id }}/">{{ company.owner.user_info.first_name }} {{ company.owner.user_info.last_name }}</a></dd>

							<!--
                            <div class="text"> </div>-->
                            {% if company.categories.count > 0 %}
                                    <dt>Категории:</dt>
								    <dd>{% for category in company.categories.all %}{{ category.name }}{% if not forloop.last %}, {% endif %}{% endfor %}</dd>
                            {% endif %}
                            </dl>



						</div>
						<ul class="options">

                            {% if request.user not in company.users.all %}
                                <li class="item"><a href="/add_to_companies/{{ company.id }}/">Добавить</a></li>
                            {% else %}
							    <li class="item"><a href="/delete_from_company/{{ company.id }}/">Удалить</a></li>
                            {% endif %}
                            
							<li class="item"><a href="/showcase/{{ company.id }}/">Витрина</a></li>
						</ul>
					</li>
                    {% endfor %}
				</ul>

    <ul class="paging">
                    {% if companies.has_previous %}
                    <li class="item"><a href="/{{ companies.previous_page_number }}/"><img class="icon" src="/media/images/icon_arrow_2.gif" width="11" height="5"></a></li>
					{% endif %}

                    {% for page in companies.paginator.page_range %}
                        {% if page == companies.number %}
                            <li class="item item_current">{{ page }}</li>
                        {% else %}
                            <li class="item"> <a href="/{{ page }}/">{{ page }}</a></li>
                        {% endif %}
                    {% endfor %}

                    {% if companies.has_next %}
					<li class="item"><a href="/{{ companies.next_page_number }}/"><img class="icon" src="/media/images/icon_arrow_1.gif" width="11" height="5"></a></li>
					{% endif %}
	</ul>

{% endblock %}